<?php
	
	$accountOldPasswordErrorMessage = '';
	$accountNewPasswordErrorMessage = '';
	$accountRetypePasswordErrorMessage = '';
	
	if(isset($_POST['btnChangePassword']))
	{		
		$accountOldPasswordErrorMessage = $accountValidationError->isEmpty(trim($_POST['old_password']),'<label class="required">Your email address is required. </label>');
		$accountNewPasswordErrorMessage = $accountValidationError->isEmpty(trim($_POST['new_password']),'<label class="required">Your email address is required. </label>');
		$accountRetypePasswordErrorMessage = $accountValidationError->isEmpty(trim($_POST['retype_password']),'<label class="required">Your password is required. </label>');
		if(!$accountRetypePasswordErrorMessage)
		{
			$accountRetypePasswordErrorMessage = $accountValidationError->isPasswordMatch(trim($_POST['new_password']),trim($_POST['retype_password']),'<label class="required">This password does not match your new password. </label>');
		}
		if($accountValidationError->status == 0)
		{
			$accountOldPasswordErrorMessage = $accountValidationError->isPasswordMatch(md5(trim($_POST['old_password'])),$currentUser->password,'<label class="required">Your password is incorrect. </label>');
		}
	}
?>

<?php
	if(isset($_POST['btnChangePassword']))
	{	
		if($accountValidationError->status == 0)
		{
			try
			{
				if($currentUser->changePassword(md5($_POST['new_password'])))
				{
					$accountMessage = '<span class="success_msg_span">assword changed successfully.</span>';
				}
				else
				{
					$accountMessage = '<span class="failed_msg_span">An error occured while changing your password.</span>';
				}
			}
			catch(Exception $ex)
			{
				$accountMessage = '<span class="failed_msg_span">'.$ex->getMessage().'</span>';
			}
		}
	}
?>